<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport"
        content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta content="telephone=no" name="format-detection" />
    <!-- 留作将来统一添加 -->
    <TEMPLATE>${TEMPLATE}</TEMPLATE>
    <title>模板html</title>
    <link rel="stylesheet" type="text/css" href="../../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../../css/aui.css" />
    <link rel="stylesheet" type="text/css" href="../../css/index.css">
    <link rel="stylesheet" type="text/css" href="../../css/data-flex.min.css">
    <style type="text/css">
        body {
            background: rgba(245, 245, 245, 1);
        }

        .vueApp {
            overflow: hidden;
        }

        .m-container-mod {
            margin: 15px;
            padding: 15px;
            background: rgba(255, 255, 255, 1);
            box-shadow: 0px 1px 8px 0px rgba(0, 0, 0, 0.02);
            border-radius: 8px;
        }

        .c-radio {
            width: 22px;
            height: 22px;
            margin-right: 15px;
            min-width: 22px;
            background: url("../../image/ui/radio.png");
            background-size: 100% 100%;
        }

        .c-radio-checked {
            width: 22px;
            height: 22px;
            margin-right: 15px;
            min-width: 22px;
            background: url("../../image/ui/checked.png");
            background-size: 100% 100%;
        }

        .o-order-goods {
            height: 80px;
            margin-top: 15px;
        }

        .o-order-goods:first-of-type {
            margin-top: 0;
        }

        .c-goods-img {
            width: 60px;
            min-width: 60px;
            height: 80px;
            margin-right: 12px;
        }

        .c-goods-name {
            height: 18px;
            font-size: 14px;
            font-weight: 400;
            color: rgba(51, 51, 51, 1);
            line-height: 18px;
            text-overflow: ellipsis;
            overflow: hidden;
            white-space: nowrap;
        }

        .o-goods-sub {
            margin-top: 10px;
            height: 18px;
        }

        .c-goods-des {
            height: 18px;
            font-size: 12px;
            font-weight: 400;
            color: rgba(191, 191, 191, 1);
            line-height: 18px;
        }

        .c-goods-count {
            height: 18px;
            font-size: 12px;
            font-weight: 400;
            color: rgba(191, 191, 191, 1);
            line-height: 18px;
        }

        .c-goods-price {
            margin-top: 10px;
            height: 20px;
            font-size: 14px;
            font-weight: 600;
            color: rgba(255, 101, 24, 1);
            line-height: 20px;
        }

        .c-btn-next {
            position: fixed;
            bottom: 0;
            width: 100%;
            height: 50px;
            background: rgba(90, 194, 255, 1);
            font-size: 16px;
            font-weight: 600;
            color: rgba(255, 255, 255, 1);
        }
    </style>
</head>

<body>
    <div class="vueApp" v-cloak>
        <div class="m-container-mod" v-for="item,index in listData" data-flex="cross:center" @click="checked(index)">
            <div :class="isChecked(index)"></div>
            <div data-flex-box="1">
                <div class="o-order-goods" data-flex>
                    <img class="c-goods-img" :src="item.productPic" alt="">
                    <div data-flex-box="1">
                        <div class="c-goods-name">{{ item.productName }}</div>
                        <div class="o-goods-sub" data-flex="main:justify">
                            <div class="c-goods-des">{{ item.sp1 }}{{ item.sp2 }}{{ item.sp3 }}</div>
                            <div class="c-goods-count">x{{ item.productQuantity }}</div>
                        </div>
                        <div class="c-goods-price">¥{{ item.productPrice }}</div>
                    </div>
                </div>
            </div>
        </div>
        <div class="c-btn-next" data-flex="main:center cross:center" @click="submitRequest">
            下一步
        </div>
    </div>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/service/service-tool.js"></script>
<script type="text/javascript" src="../../script/service/service-app.js"></script>
<script type="text/javascript" src="../../script/service/service-user.js"></script>
<script type="text/javascript" src="../../script/service/service-logic.js"></script>
<script type="text/javascript" src="../../script/jquery.min.js"></script>
<script type="text/javascript" src="../../script/vue.min.js"></script>
<script type="text/javascript">
    // html 的引号一律为双引号(""),js 为单引号('')
    var USER, $S, vm, pageParam;
    apiready = function () {
        $S = SERVICE();
        USER = USER();
        console.log(JSON.stringify(api.pageParam) + '=====pageParam');
        pageParam = api.pageParam;
        fnInit();
    };
    // 初始化
    function fnInit() {
        vm = new Vue({
            el: '.vueApp',
            data: {
                checkeds: [],
                listData: pageParam.order.orderItemList
            },
            methods: {
                checked: function(index) {
                    var result = this.checkeds.indexOf(index);
                    if(result !== -1) {
                        this.checkeds.splice(result, 1);
                    } else {
                        this.checkeds.push(index);
                    }
                },
                isChecked: function(index) {
                    return this.checkeds.indexOf(index) !== -1 ? 'c-radio-checked' : 'c-radio';
                }
            }
        });
    }

    // 获取页面数据
    // function getData() {
    //     var url = 'single/oms/detail';
    //     var params = {};
    //     var callback = function (data) {

    //     };
    //     MALLGET(url, params, callback);
    // }

    // 提交
    function submitRequest() {
        if(vm.checkeds.length === 0) {
            fnToast('至少选中一项');
            return;
        }
        var items = [];
        vm.checkeds.forEach(function(item) {
            items.push(pageParam.order.orderItemList[item].id);
        });
        fnOpenPublicWin('提交售后', 'teacher/post_sale_submit', {
            orderId: pageParam.order.id,
            items: items,
            refreshWin: pageParam.refreshWin,
            refreshFrm: pageParam.refreshFrm
        });
        fnDelayCloseWin(500);
    }
</script>

</html>